#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# @Time    : 2025/9/26 18:30
# @Author  : WXY
# @File    : splashscreen_ui_safe.py
# @PROJECT_NAME: youtubedown_gui
# @PRODUCT_NAME: PyCharm
# -------------------------------------------------------------------------------

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
                            QMetaObject, QObject, QPoint, QRect,
                            QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
                           QFont, QFontDatabase, QGradient, QIcon,
                           QImage, QKeySequence, QLinearGradient, QPainter,
                           QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QMainWindow,
                               QProgressBar, QSizePolicy, QSpacerItem, QVBoxLayout,
                               QWidget)


class Ui_splashscreen(object):
    def setupUi(self, splashscreen):
        if not splashscreen.objectName():
            splashscreen.setObjectName(u"splashscreen")
        splashscreen.resize(800, 600)
        splashscreen.setStyleSheet(u"QMainWindow {\n"
                                   "    background: qlineargradient(x1:0, y1:0, x2:1, y2:1, \n"
                                   "        stop:0 #0f0f23, \n"
                                   "        stop:0.3 #1a1a2e, \n"
                                   "        stop:0.6 #16213e, \n"
                                   "        stop:1 #0f3460);\n"
                                   "    border-radius: 16px;\n"
                                   "}\n"
                                   "\n"
                                   "QWidget#centralwidget {\n"
                                   "        background: transparent;\n"
                                   "    border-radius: 16px; \n"
                                   "}")
        self.centralwidget = QWidget(splashscreen)
        self.centralwidget.setObjectName(u"centralwidget")
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)

        self.horizontalLayout_2.addItem(self.horizontalSpacer_3)

        self.closeButton = QLabel(self.centralwidget)
        self.closeButton.setObjectName(u"closeButton")
        self.closeButton.setMinimumSize(QSize(30, 30))
        self.closeButton.setMaximumSize(QSize(30, 30))
        font = QFont()
        font.setFamilies([u"Arial"])
        font.setPointSize(14)
        font.setBold(True)
        self.closeButton.setFont(font)
        self.closeButton.setStyleSheet(u"QLabel {\n"
                                       "    background-color: transparent;\n"
                                       "    color: white;\n"
                                       "    border: 2px solid white;\n"
                                       "    border-radius: 15px;\n"
                                       "    text-align: center;\n"
                                       "}\n"
                                       "\n"
                                       "QLabel:hover {\n"
                                       "    background-color: rgba(255, 255, 255, 0.1);\n"
                                       "}")
        self.closeButton.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_2.addWidget(self.closeButton)

        self.verticalLayout.addLayout(self.horizontalLayout_2)

        self.verticalSpacer = QSpacerItem(757, 100, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer)

        self.logoLabel = QLabel(self.centralwidget)
        self.logoLabel.setObjectName(u"logoLabel")
        sizePolicy = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.logoLabel.sizePolicy().hasHeightForWidth())
        self.logoLabel.setSizePolicy(sizePolicy)
        self.logoLabel.setMinimumSize(QSize(50, 50))
        self.logoLabel.setMaximumSize(QSize(50, 50))

        # 安全设置pixmap
        try:
            pixmap = QPixmap(u":/img/logo.png")
            if not pixmap.isNull():
                self.logoLabel.setPixmap(pixmap)
                print("✅ Logo图片加载成功")
            else:
                print("⚠️ Logo图片为空，使用默认文本")
                self.logoLabel.setText("🎬")
                self.logoLabel.setStyleSheet("QLabel { color: white; font-size: 24px; }")
        except Exception as e:
            print(f"❌ Logo图片加载失败: {e}")
            self.logoLabel.setText("🎬")
            self.logoLabel.setStyleSheet("QLabel { color: white; font-size: 24px; }")

        self.logoLabel.setScaledContents(True)
        self.logoLabel.setAlignment(Qt.AlignCenter)

        self.horizontalLayout.addWidget(self.logoLabel)

        self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer_2)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.verticalSpacer_5 = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer_5)

        self.titleLabel = QLabel(self.centralwidget)
        self.titleLabel.setObjectName(u"titleLabel")
        font1 = QFont()
        font1.setFamilies([u"微软雅黑"])
        font1.setPointSize(28)
        font1.setBold(True)
        self.titleLabel.setFont(font1)
        self.titleLabel.setStyleSheet(u"QLabel {\n"
                                      "    color: white;\n"
                                      "    background: transparent;\n"
                                      "}")
        self.titleLabel.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.titleLabel)

        self.verticalSpacer_3 = QSpacerItem(17, 27, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)

        self.verticalLayout.addItem(self.verticalSpacer_3)

        self.progressBar = QProgressBar(self.centralwidget)
        self.progressBar.setObjectName(u"progressBar")
        self.progressBar.setMinimumSize(QSize(0, 10))
        self.progressBar.setMaximumSize(QSize(16777215, 10))
        self.progressBar.setLayoutDirection(Qt.LeftToRight)
        self.progressBar.setAutoFillBackground(False)
        self.progressBar.setStyleSheet(u"QProgressBar {\n"
                                       "    border: none;\n"
                                       "    border-radius: 8px;\n"
                                       "    background-color: rgba(255, 255, 255, 0.2);\n"
                                       "    color: white;\n"
                                       "    text-align: center;\n"
                                       "    font-weight: bold;\n"
                                       "}\n"
                                       "\n"
                                       "QProgressBar::chunk {\n"
                                       "    background: qlineargradient(x1:0, y1:0, x2:1, y2:0, \n"
                                       "        stop:0 #00d4ff, \n"
                                       "        stop:0.5 #0099cc, \n"
                                       "        stop:1 #006699);\n"
                                       "    border-radius: 8px;\n"
                                       "}")
        self.progressBar.setValue(24)

        self.verticalLayout.addWidget(self.progressBar)

        self.verticalSpacer_4 = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer_4)

        self.versionLabel = QLabel(self.centralwidget)
        self.versionLabel.setObjectName(u"versionLabel")
        font2 = QFont()
        font2.setFamilies([u"Arial"])
        font2.setPointSize(12)
        self.versionLabel.setFont(font2)
        self.versionLabel.setStyleSheet(u"QLabel {\n"
                                        "    color: rgba(255, 255, 255, 0.7);\n"
                                        "    background: transparent;\n"
                                        "}")
        self.versionLabel.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.versionLabel)

        self.verticalSpacer_2 = QSpacerItem(20, 200, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer_2)

        splashscreen.setCentralWidget(self.centralwidget)

        self.retranslateUi(splashscreen)

        QMetaObject.connectSlotsByName(splashscreen)

    # setupUi

    def retranslateUi(self, splashscreen):
        splashscreen.setWindowTitle(QCoreApplication.translate("splashscreen", u"🎬 YouTube 视频下载器", None))
        self.closeButton.setStatusTip(QCoreApplication.translate("splashscreen", u"关闭", None))
        self.closeButton.setText(QCoreApplication.translate("splashscreen", u"×", None))
        self.logoLabel.setText("")
        self.titleLabel.setText(QCoreApplication.translate("splashscreen", u"🎬 YouTube 视频下载器", None))
        self.progressBar.setFormat(QCoreApplication.translate("splashscreen", u"%p%", None))
        self.versionLabel.setText(QCoreApplication.translate("splashscreen", u"V1.0.0.1", None))
    # retranslateUi